package com.tyj.gulimall.search.controller;

import com.tyj.gulimall.search.service.SearchService;
import com.tyj.gulimall.search.vo.SearchParam;
import com.tyj.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class SearchController {

    @Autowired
    SearchService searchService;

    @RequestMapping("/list.html")
    public String listPage(SearchParam searchParam, Model model, HttpServletRequest request){
        String queryString=request.getQueryString();
        searchParam.set_queryString(queryString);
        SearchResult result= searchService.listPage(searchParam);
        model.addAttribute("result",result);
        System.out.println("result数据测试="+result);
        return "list";
    }

}
